package com.plian.system.dao.bt.baseinfo;

import com.plian.Tools.Tree;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.model.page.Page;
import com.plian.system.vo.fr.bulletin.BulletinTypeVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class BaseInfoDao {

    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 新增
     *
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("BaseInfoMapper.save", pd);
    }
    
    /**
     * 修改
     *
     * @param pd
     * @throws Exception
     */
    public void edit(PageData pd) throws Exception {
        dao.update("BaseInfoMapper.edit", pd);
    }

    /**
     * 列表
     *
     * @param page
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public List<PageData> list(Page page) throws Exception {
        return (List<PageData>) dao.findForList("BaseInfoMapper.datalistPage", page);
    }

    /**
     * 列表(全部)
     *
     * @param pd
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public List<PageData> listAll(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("BaseInfoMapper.listAll", pd);
    }

    /**
     * 通过id获取数据
     *
     * @param pd
     * @throws Exception
     */
    public PageData findById(PageData pd) throws Exception {
        return (PageData) dao.findForObject("BaseInfoMapper.findById", pd);
    }

    /**
     * 批量删除
     *
     * @param pd
     * @throws Exception
     */
    public void delete(PageData pd) throws Exception {
        dao.delete("BaseInfoMapper.delete", pd);
    }

    /**
     * 通过父节点Code获取子数据
     * @param Code
     * @return
     * @throws Exception
     */
    public List<PageData> findbyParentid(String Code) throws  Exception{
        return (List<PageData>) dao.findForList("BaseInfoMapper.findbyParentid",Code);
    }
    public List<PageData> findByNames(List names) throws  Exception{
        return (List<PageData>) dao.findForList("BaseInfoMapper.findByNames",names);
    }

    /**
     * 通过Code获取子数据
     * @param Code
     * @return
     * @throws Exception
     */
    public PageData findbycode(String Code) throws Exception {
        return (PageData) dao.findForObject("BaseInfoMapper.findbycode", Code);
    }
    public List<PageData> findbycodes(List<String> Codes) throws Exception {
        return (List<PageData>) dao.findForList("BaseInfoMapper.findbycodes", Codes);
    }

    public List<Tree> findTree(PageData pageData) throws  Exception{
        return (List<Tree>) dao.findForList("BaseInfoMapper.findTree",pageData);
    }


    /**
     * 获取银行字典 金蝶对接用
     * @return
     * @throws Exception
     */
    public List<BulletinTypeVO> findBulletin(String year) throws  Exception{
        PageData pd = new PageData();
        pd.put("year", year);
        return (List<BulletinTypeVO>) dao.findForList("BaseInfoMapper.findBulletin", pd);
    }

    /**
     * 根据code获得name
     */
    public PageData findnamebycode(String Code) throws Exception {
        return (PageData) dao.findForObject("BaseInfoMapper.findnamebycode", Code);
    }
}
